<!DOCTYPE html>
<html lang="zh_CN">
    <meta charset="utf-8">
    <head>
        <link rel="stylesheet" href="/static/bootstrap/css/jquery.treegrid.css"/>
        <#include "/common/base_include.ftl"/>
        <script type="text/javascript" src="/static/bootstrap/bootstrap-table/jquery.treegrid.js"></script>
        <script type="text/javascript" src="/static/bootstrap/bootstrap-table/jquery.treegrid.extension.js"></script>
        <script type="text/javascript" src="/static/bootstrap/bootstrap-table/jquery.treegrid.bootstrap3.js"></script>
    </head>
    <body>
        <div class="wrapper wrapper-content ">
            <div class="col-sm-12">
                <div class="ibox">
                    <div class="ibox-body">
                        <table id="exampleTable" data-mobile-responsive="true">  </table>
                    </div>
                </div>
            </div>
        </div>
<script type="text/javascript">
var prefix = "/sys/menu";
var columns=[];
var param;
$(function(){
   columns= [{
                title: '编号',
                field: 'menuId',
                visible: false,
                align: 'center',
                valign: 'center',
                width: '5%'
            },
            {
                title: '名称',
                valign: 'center',
                field: 'name',
                width: '20%'
            },
            {
                title: '图标',
                field: 'icon',
                align: 'center',
                valign: 'center',
                width: '5%',
                formatter: function (item, index) {
                    return item.icon == null ? ''
                        : '<i class="' + item.icon
                        + ' fa-lg"></i>';
                }
            },
            {
                title: '类型',
                field: 'type',
                align: 'center',
                valign: 'center',
                width: '10%',
                formatter: function (item, index) {
                    if (item.type === 0) {
                        return '<span class="label label-primary">目录</span>';
                    }
                    if (item.type === 1) {
                        return '<span class="label label-success">菜单</span>';
                    }
                    if (item.type === 2) {
                        return '<span class="label label-warning">按钮</span>';
                    }
                }
            },
            {
                title: '地址',
                valign: 'center',
                width: '20%',
                field: 'url'
            },
            {
                title: '权限标识',
                valign: 'center',
                width: '20%',
                field: 'perms'
            },
            {
                title: '操作',
                field: 'id',
                align: 'center',
                valign: 'center',
                formatter: function (row, index) {
                 if(row.menuId=="0"){
                    var add = '<@shiro.hasPermission name="system:sysDept:add">' +
                    '<a class="btn btn-primary btn-sm " href="#" title="增加下級"  mce_href="#" onclick="add(\''
                    + row.menuId  + '\')"><i class="fa fa-plus"></i></a>' +
                    '</@shiro.hasPermission>';
                    return add;
                 }
                var e = '<@shiro.hasPermission name="sys:menu:edit">' +
                    '<a class="btn btn-primary btn-sm " href="#" title="编辑"  mce_href="#" onclick="edit(\''
                    + row.menuId + '\')"><i class="fa fa-edit"></i></a>' +
                    ' </@shiro.hasPermission>';
                var a = '<@shiro.hasPermission name="sys:menu:add">' +
                    '<a class="btn btn-primary btn-sm " href="#" title="增加"  mce_href="#" onclick="add(\''
                    + row.menuId  + '\')"><i class="fa fa-plus"></i></a>' +
                    '</@shiro.hasPermission>';
                var d = '<@shiro.hasPermission name="sys:menu:remove">' +
                    '<a class="btn btn-warning btn-sm " href="#" title="删除"  mce_href="#" onclick="removeone(\''
                    + row.menuId
                    + '\')"><i class="fa fa-remove"></i></a>' +
                    ' </@shiro.hasPermission>';
                return e + a + d;
                }
            }];
    param={id:"menuId",code:"menuId",parentCode:"parentId",sort:"order_num"};
    loadTreeTable(prefix + '/list',columns,param,"")
});
function reLoad() {
	loadTreeTable(prefix + '/list',columns,param,"")
}
function add(pId) {
    layer_open_1(prefix + '/add/' + pId, '增加',function (index,layero) {
        current_index=index;
        $(layero).find('form').submit();
    });
}
function edit(id) {
    layer_open_1(prefix + '/edit/' + id, '编辑',function (index,layero) {
        current_index=index;
        $(layero).find('form').submit();
 });
}
function removeone(id) {
    remove2( prefix + "/remove",{ 'id' : id });
}
        </script>
    </body>

</html>